package com.woniumall.pojo;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @auther linke
 * @create 2021-10-28 14:05
 */
public class OrderItem implements Serializable {
    private int id;
    private int orderid;
    private int goodsid;
    private int goodsnum;
    private BigDecimal prices;
    private Goods  goods;//增加一个字段用于在订单详情页面显示书籍信息
    private BigDecimal totalPrice;//订单小计金额

    public OrderItem() {
    }

    @Override
    public String toString() {
        return "OrderItem{" +
                "id=" + id +
                ", orderid=" + orderid +
                ", goodsid=" + goodsid +
                ", goodsnum=" + goodsnum +
                ", prices=" + prices +
                ", goods=" + goods +
                ", totalPrice=" + totalPrice +
                '}';
    }

    public OrderItem(int id, int orderid, int goodsid, int goodsnum, BigDecimal prices, Goods goods, BigDecimal totalPrice) {
        this.id = id;
        this.orderid = orderid;
        this.goodsid = goodsid;
        this.goodsnum = goodsnum;
        this.prices = prices;
        this.goods = goods;
        this.totalPrice = totalPrice;
    }

    public BigDecimal getTotalPrice() {//将小计计算后返回
        BigDecimal num = new BigDecimal(goodsnum);
        totalPrice = num.multiply(prices);
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public OrderItem(int id, int orderid, int goodsid, int goodsnum, BigDecimal prices, Goods goods) {
        this.id = id;
        this.orderid = orderid;
        this.goodsid = goodsid;
        this.goodsnum = goodsnum;
        this.prices = prices;
        this.goods = goods;
    }

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public OrderItem(int orderid, int goodsid, int goodsnum, BigDecimal prices) {
        this.orderid = orderid;
        this.goodsid = goodsid;
        this.goodsnum = goodsnum;
        this.prices = prices;
    }
    public OrderItem(int id, int orderid, int goodsid, int goodsnum, BigDecimal prices) {
        this.id = id;
        this.orderid = orderid;
        this.goodsid = goodsid;
        this.goodsnum = goodsnum;
        this.prices = prices;
    }



    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getOrderid() {
        return orderid;
    }

    public void setOrderid(int orderid) {
        this.orderid = orderid;
    }

    public int getGoodsid() {
        return goodsid;
    }

    public void setGoodsid(int goodsid) {
        this.goodsid = goodsid;
    }

    public int getGoodsnum() {
        return goodsnum;
    }

    public void setGoodsnum(int goodsnum) {
        this.goodsnum = goodsnum;
    }

    public BigDecimal getPrices() {
        return prices;
    }

    public void setPrices(BigDecimal prices) {
        this.prices = prices;
    }

}
